// pages/component/list/list.js
var util = require('../../../utils/util.js')
var wxRequest = require('../../../utils/wxRequest.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id:0,
    page:1,
    picList:[],
    stopLoadMoreTiem:false,
    
    showModal:false,
    showName:'aa',
    showIngImg:'https://static.ath365.com/Frj0tYNZdiEK4ZgJQsVocDsnZgDn'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var id = options.id;
    this.setData({id:id});
    this.getPackages(id);
    this.getPackages(id);
  },

  
  showTip:function (e) {
    var id = e.currentTarget.id,
    url = '/pages/basics/detail/detail?id=' + id;
    wx.navigateTo({
      url: url
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  //上拉
  lower:function(){
    var that = this;
    that.setData({isPull:false});
    console.log("lower");
    if (that.stopLoadMoreTiem) {
      return;
    }
    this.setData({
      page: this.data.page + 1 //上拉到底时将page+1后再调取列表接口
    });
    this.getPackages();
  },
  getPackages:function(){
    var that = this;
    var data = {
      id: that.data.id,
      page : that.data.page
    }
    var res = util.getSinglePage(data);
    res.then(function(json){
      
          that.setData({
            picList:that.data.picList.concat(JSON.parse(json.data.result)),
          });
          that.stopLoadMoreTiem = false;
    });
  },
  preventHide:function(e){
    this.setData({showModal:false});
  },
  showTip:function (e) {
    var id = e.currentTarget.id,
    title = e.currentTarget.dataset.name,
    img = e.currentTarget.dataset.path;

    this.setData({
      showIngImg:img,
      showName:title,
      showModal:true
    });
  },
  // 禁止屏幕滚动
  preventTouchMove:function () {
  }
})